<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\Custom;

class CustomController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new Custom();
    }

    //自定义活动规则新增
    public function customRuleAdd(Request $request){
        $res = $this->model->customRuleAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动新增活动规则数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动编辑规则
    public function customRuleEdit(Request $request){
        $res = $this->model->customRuleEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动编辑活动规则数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动规则列表
    public function customRule(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $customId = $request->get('custom_id',0);
        $res = $this->model->customRule($page, $limit, $customId);
        return $this->toJson(self::SUCCESS,$res);
    }

    //自定义活动删除规则
    public function customRuleDel(Request $request){
        $res = $this->model->customRuleDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动删除规则数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动人气票下发配置-新增
    public function customTicketConfigEdit(Request $request){
        $res = $this->model->customTicketConfigEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动新增人气票下发数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //获取人气票基本配置
    public function customTicketConfig(){
        $res = $this->model->customTicketConfig();  
        return $this->toJson(self::SUCCESS,$res);
    }

    //获取自定义游戏类型
    public function customTicketGameType(){
        $res = $this->model->customTicketGameType();  
        return $this->toJson(self::SUCCESS,$res);
    }

    //自定义活动人气票新增游戏
    public function customTicketGameAdd(Request $request){
        $res = $this->model->customTicketGameAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动新增人气票游戏数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动人气票新增游戏
    public function customTicketGameEdit(Request $request){
        $res = $this->model->customTicketGameEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动编辑人气票游戏数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动人气票删除游戏
    public function customTicketGameDel(Request $request){
        $res = $this->model->customTicketGameDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动删除人气票游戏数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义游戏人气票列表
    public function customTicketGame(Request $request){
        $page = $request->get('page',1);//当前页
        $limit = $request->get('limit',10);//每一页条数
        $customId = $request->get('custom_id',0);
        $res = $this->model->customTicketGame($page,$limit,$customId);
        return $this->toJson(self::SUCCESS,$res);
    }

    //自定义活动清空数据
    public function customClear(Request $request){
        $res = $this->model->customClear($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动清空数据');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动新增
    public function customAdd(Request $request){
        $res = $this->model->customAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动编辑
    public function customEdit(Request $request){
        $res = $this->model->customEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单新增
    public function customRankAdd(Request $request){
        $res = $this->model->customRankAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单编辑
    public function customRankEdit(Request $request){
        $res = $this->model->customRankEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单删除
    public function customRankDel(Request $request){
        $res = $this->model->customRankDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单奖励新增
    public function customRankRewardAdd(Request $request){
        $res = $this->model->customRankRewardAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单奖励新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单奖励编辑
    public function customRankRewardEdit(Request $request){
        $res = $this->model->customRankRewardEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单奖励编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动榜单奖励删除
    public function customRankRewardDel(Request $request){
        $res = $this->model->customRankRewardDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动榜单奖励删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动列表
    public function customList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->customList($request));
    }

    //自定义活动榜单列表
    public function customRankList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->customRankList($request));
    }

    //自定义活动榜单奖励列表
    public function customRankRewardList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->customRankRewardList($request));
    }

    //自定义活动留言板新增
    public function customLybAdd(Request $request){
        $res = $this->model->customLybAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动留言板新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动留言板编辑
    public function customLybEdit(Request $request){
        $res = $this->model->customLybEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动留言板编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //自定义活动留言板列表
    public function customLybList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->customLybList($request));
    }
    
    //后台-自定义活动充值活动新增
    public function customRechargeAdd(Request $request){
        $res = $this->model->customRechargeAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动充值任务新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义活动充值编辑
    public function customRechargeEdit(Request $request){
        $res = $this->model->customRechargeEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动充值任务编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义充值活动删除
    public function customRechargeDel(Request $request){
        $res = $this->model->customRechargeDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动充值任务删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义充值活动列表
    public function customRechargeList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $customId = $request->get('custom_id',0);
        $data = $this->model->customRechargeList($page, $limit, $customId);
        return $this->toJson(self::SUCCESS,$data);
    }

    //后台-自定义盖楼活动配置
    public function customBridgeAdd(Request $request){
        $res = $this->model->customBridgeAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼活动编辑配置
    public function customBridgeEdit(Request $request){
        $res = $this->model->customBridgeEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼删除配置
    public function customBridgeDel(Request $request){
        $res = $this->model->customBridgeDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼配置列表
    public function customBridgeList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $customId = $request->get('custom_id',0);
        $data = $this->model->customBridgeList($page, $limit, $customId);
        return $this->toJson(self::SUCCESS,$data);
    }

    //后台-自定义盖楼配置奖励楼层
    public function customBridgeAwardAdd(Request $request){
        $res = $this->model->customBridgeAwardAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼奖励新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼编辑奖励配置楼层
    public function customBridgeAwardEdit(Request $request){
        $res = $this->model->customBridgeAwardEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼奖励编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼删除奖励配置
    public function customBridgeAwardDel(Request $request){
        $res = $this->model->customBridgeAwardDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '自定义活动-盖楼奖励删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //后台-自定义盖楼奖励列表
    public function customBridgeAwardList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $bridegeId = $request->get('bridge_id',0);
        $data = $this->model->customBridgeAwardList($page, $limit, $bridegeId);
        return $this->toJson(self::SUCCESS,$data);
    }
}
